<?php
/**
 * Created by 荣耀电竞.
 * User: 林子彦 <278805354@qq.com>
 * Date: 2018/6/8 0008
 * Time: 21:14
 */
namespace App\Base\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class AreaModel extends Model{
    use SoftDeletes;
    /**
     * 表名
     * @var string
     */
    public $table="area";
    /**
     * 时间自动
     * @var bool
     */
    public $timestamps=true;
    /**
     * The name of the "created at" column.
     *
     * @var string
     */
    const CREATED_AT = 'create_time';  //修改添加时间字段
    /**
     * The name of the "updated at" column.
     *
     * @var string
     */
    const UPDATED_AT = 'update_time';

    /**
     * 删除
     */
    const DELETED_AT = 'delete_time';
    /**
     * 模型的日期字段保存格式。
     */
    protected $dateFormat = 'U';
   protected $appends = ["city"];
    //protected $appends = ["province"];

    public function getProvinceAttribute()
    {
        $mobile = self::newQuery()->where("area_id",$this->pid)->value("title");
        return $mobile ?? "";
    }
    /**
     * 手机号
     * @return mixed|string
     */
    public function getCityAttribute()
    {
        $mobile = self::newQuery()->where("area_id",$this->pid)->value("title");
        return $mobile ?? "";
    }
    /**
     * 隐藏字段
     * @var array
     */
    protected $hidden = ['create_time','update_time','delete_time'];
}